/*
 * @Descripttion:
 * @version:
 * @Author: cxguo
 * @Date: 2019-10-10 21:42:10
 * @LastEditors: cxguo
 * @LastEditTime: 2019-10-10 22:00:05
 */

import clonedeep from 'clonedeep'
import { amount } from '@/libs/tools.js'

/**
  * 商品数据 -> 单据明细数据
  * @param {商品数据} goodObj
  */
export const good2billdata = function(goodObjArray) {
  const result = clonedeep(goodObjArray)
  result.forEach(item => {
    item.goodsId = item.id
    item.price = item.lastPurchasingPrice
    item.total = amount(item.lastPurchasingPrice).multiply(item.num).format()
  })
  return result
}
